home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
MacWorld 1999 June
/
Macworld (1999-06).dmg
/
Serious Software
/
Masterapp demo
/
masterapp.dir
/
00002_Script_Most of the code
< prev
next >
Wrap
Text File
|
1999-03-17
|
4KB
|
178 lines
-- MasterApp example code
--
----- Initialization ---------------------
on startMovie
eraseFields
checkForXtras
initMasterApp("demo")
end
on eraseFields
repeat with nam in ["currentFile","status","Task List","Task Name","Task ID","Task Parent"]
put "" into field nam
end repeat
end
on checkForXtras
if not xtracheck("FileIO") then
alert "This demo requires the FileIO Xtra to work"
end if
if not xtracheck("MasterApp") then
alert "This demo requires the MasterApp Xtra to work"
end if
end
on xtracheck xtraName
-- check if an xtra is present
set flag = 0
repeat with a = 1 to the number of Xtras
if the name of xtra a = xtraName then
set flag = 1
end if
end repeat
return flag
end
on initMasterApp serialNumber
-- Initializes and registers the Xtra
-- Call this once from startMovie handler of first movie.
--
-- serialNumber: string containing serialNumber or "demo"
--
-- EX: initMasterApp("demo")
-- EX: initMasterApp("37483294827kio")
--
if serialNumber <> "demo" then
register(xtra "MasterApp", serialNumber)
end if
end
--------------------------------------------
-- When user clicks on task list field, put
-- task info in fields to right
on clickLine lineText
-- put information from line user clicked on screen
--
global taskID
set the itemDelimiter = ","
clearTaskInfo
set taskID = value(item 2 of lineText)
set taskName = item 1 of lineText
set taskParent = item 3 of lineText
refreshTaskInfo(taskName,taskID,taskParent)
end
on clearTaskInfo
global taskID
set taskID = 0
put "" into field "Task Name"
put "" into field "Task ID"
put "" into field "Task Parent"
end
on refreshTaskInfo taskName,taskID,taskParent
put taskName into field "Task Name"
put taskID into field "Task ID"
put taskParent into field "Task Parent"
end
---------------------------------------------
on feedProcess waitTicks
-- Make Director give over the specified processing time to allow
-- other tasks to process
--
-- EX: feedProcess(30)
--
set waitOver = the ticks + waitTicks
repeat while the ticks < waitOver
mappfeedGenericTimeSlice
end repeat
end
------------------- Buttons ------------------
on pickFileButton
-- Use FileIO's displayOpen dialog to pick a file to work with
--
set y = new(xtra "FileIO")
set filePath = displayOpen(y)
put filePath into field "currentFile"
set y = 0
end
on updateTaskListButton
-- get list of currently running processes
--
set tasks = mappgetTaskList()
put tasks into field "Task List"
end
on launchButton
-- launch an application
--
set filePath = field "currentFile"
set err = mapplaunch(filePath,"")
put checkErr("launch",err) into field "status"
end
on openDocButton
-- open a document with its associated application
--
set filePath = field "currentFile"
set err = mappopenDocument(filePath)
put checkErr("openDocument",err) into field "status"
end
on printDocButton
-- open a document with its associated application
-- and print it
--
set filePath = field "currentFile"
set err = mappprintDocument(filePath)
put checkErr("printDocument",err) into field "status"
end
on launchHiddenButton
-- launch but don't show an application
--
set filePath = field "currentFile"
set err = mapplaunchHidden(filePath,"")
put checkErr("launchHidden",err) into field "status"
end
on locateExecutableButton
-- return path to an application from name
--
set appName = field "currentFile"
set path = mapplocateExecutable(appname)
put path into field "status"
end
on quitTaskButton
-- close the application's main window on Win to quit
-- or use rudeQuit on Mac to quit
--
global taskID
if taskID <> 0 and not(voidP(taskID)) then
if the machineType = 256 then
set taskWindowlist = mappgetTaskWindowIDs(taskID)
-- main window of app usually the first one
set mainWindow = value(word 1 of taskWindowList)
mappwindowToFront(mainWindow)
mappcloseWindow(mainWindow)
-- give process time to quit
feedProcess(30)
else
mapptaskToFront(taskID)
-- make sure app has focus before quit
feedProcess(30)
mapprudeQuitTask(taskID,0)
-- give process time to quit
feedProcess(30)
end if
end if
end